package com.endoc.designpattern.faced;

import com.endoc.designpattern.compose.DistrictNode;
import com.endoc.designpattern.compose.Node;

/**
 * 物流服务
 */
public class SendService {

    /**
     * 发送服务
     */
    public void doSend(){
        /*
         * 组合模式,将多个类似的节点用一个类表示
         * */
        Node rootNode = new DistrictNode("根节点");
        //一线目录
        rootNode.addNode(new DistrictNode("上海"));
        rootNode.addNode(new DistrictNode("天津"));
        DistrictNode beiJingDistrictNode = new DistrictNode("北京");
        rootNode.addNode(beiJingDistrictNode);
        beiJingDistrictNode.addNode(new DistrictNode("海淀区"));
        beiJingDistrictNode.addNode(new DistrictNode("西城区"));
        DistrictNode districtNode2 = new DistrictNode("朝阳区");
        beiJingDistrictNode.addNode(districtNode2);
        districtNode2.addNode(new DistrictNode("三里屯"));
        districtNode2.addNode(new DistrictNode("朝阳外街"));
        System.out.println("\n-------------组合模式---------------");
        System.out.println(rootNode.toString());

    }

}
